<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        电梯列表-计划
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../css/bootstrap.css">
    <link rel="stylesheet" href="../../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .layui-table-page select {
            height: 22px;
        }
    </style>
</head>

<body>
<div>

    <div class="main_box">
        <div class="panel-heading">
            <h2>电梯计划</h2>
        </div>
    </div>

    <form class="layui-form x-center">

        <div class="layui-form-pane" style="margin-top: 15px; text-align: left; text-indent: 20px;" id="app">

            <h3>电梯信息</h3>
            <div>
                <ul class="elevatorBase">
                    <li>使用单位：<span class="wygroup">{{companyname}}</span></li>
                    <li>项目名称：<span class="plot">{{projectname}}</span></li>
                    <li>电梯位置：<span class="position">{{address}}</span></li>
                </ul>
            </div>

            <div class="layui-form-item">
                <p>提示:选择下次保养时间</p>
                <label class="layui-form-label">保养时间</label>
                <div class="layui-input-block">
                    <input  autocomplete="off"  class="layui-input" placeholder="下次保养时间" name="nextmaintenanceDate" id="nextmaintenanceDate">
                </div>
            </div>

            <div style="text-align: center" class="layui-form-item">
                <button class="layui-btn" type="button" lay-filter="sub" lay-submit="sub">
                    确定
                </button>
            </div>
        </div>
    </form>



</div>
</body>


<script type="text/javascript" src="../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../js/pub.js"></script>
<script type="text/javascript" src="../../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../../js/vue.min.js"></script>
<!-- <script src="lib/layui/layui.js" charset="utf-8"></script> -->
<script src="../../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element;//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var form = layui.form;
        okLoading.close($);
    });
</script>


<script>
    var recordId = getQueryVariable("recordId");

    layui.use(['laydate', 'form','layer'],
        function () {
            var laydate = layui.laydate;
            var form = layui.form;
            var layer = layui.layer;


            //执行一个laydate实例
            laydate.render({
                trigger: 'click',
                type: 'date',
                elem: '#nextmaintenanceDate' //指定元素
            });


            //监听审批提交
            form.on('submit(sub)',
                function (data) {
                    var nextmaintenanceDate = $("#nextmaintenanceDate").val();
                    if(nextmaintenanceDate== ""){
                        layer.msg("请选择下次保养时间！", {
                            icon: 5
                        });
                        return false;
                    }else{
                        let form = data.field;

                        form.id =recordId;
                        form.userId=$userId;
                        let request = {
                            url: 'maintenance/elevator/plan',
                            data: form,
                            method: "post",
                        };
                        sendRequest(request, (data) => {
                            if (data.code === 0) {
                                layer.alert("操作成功", {
                                        icon: 6
                                    },
                                    function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                        parent.reload();
                                    });
                            } else {
                                layer.alert(data.msg, {
                                    icon: 5
                                })
                            }
                        });
                        return false;
                    }


                });
        });



    const vm = new Vue({
        el: "#app",
        data:{
            companyname:null,
            projectname:null,
            address:null,

        },
        created() {
            let request = {
                url: 'maintenance/elevator/detail',
                data: {
                    id: recordId,
                    userId:$userId
                },
                method: "POST"
            }
            sendRequest(request, (res) => {
                this.companyname=res.data.elevator.company.name;
                this.projectname=res.data.elevator.project.name;
                this.address=res.data.elevator.address;


            });

        },
        computed: {},
        methods: {

        },


    });

</script>


</html>
